home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / MBBS.SLT < prev    next >
Text File  |  1991-01-24  |  17KB  |  464 lines

  1. //-----------------------------------------------------------
  2. // MBBS.SL? Automatic logging into an MBBS system.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs, BEFORE you use it. Then recompile with CS MBBS.
  6.  
  7.  
  8. // Note: Lines commented out with //!! are not used in this script,
  9. // but in other, related ones. Please don't delete them; they may
  10. // become useful later.
  11. //-----------------------------------------------------------
  12.  
  13. str thisBBStype[] = "MBBS"   // This BBS type.      
  14.    ,line      [80]           // General input line.
  15.    ,filelist  [12]           // Name of file list for this BBS.
  16.    ,myprot     [2]           // Chosen protocol.
  17.    ,hisprot    [2]           // MBBS's translation.
  18.  
  19.                              // For the Global storage:
  20.    ,global   []="GLOBAL"     // Global script.
  21.    ,bbstype  []="BTYPE"      // BBS type.
  22.    ,short    []="SHORT"      // Short BBS name.
  23.    ,hprot    []="HPROT"      // MBBS's interpretation of protocol
  24.    ,prompt   []="PROMPT"     // Current prompt (global name)
  25.    ,filist   []="FILIST"     // Name of file list.
  26.    ,mscript  []="MDOOR"      // Name of mail door.
  27.    ,mailup   []="MAILUP"     // Name of upload mail script.
  28.    ,command[10]              // Current prompt (value)
  29.    ;     
  30.  
  31. int y=4                                  // Y coordinate for messages
  32.    ,tol = 300                            // No activity for 30 seconds
  33.    ,t1, t2, t3, t4, t5, t6, t7           // makes script time out. 
  34.    ,stat, tmark
  35.    ,messages                             // Messages to fetch?
  36.    ,nocon                                // No conference status.
  37.    ;
  38.  
  39. //-----------------------------------------------------------   
  40. // Script starts here.
  41. //-----------------------------------------------------------   
  42.  
  43. main()
  44. {
  45. int filter
  46.    ,i, l
  47.    ,mo 
  48.    ,FTD                                  // Files to Download
  49.    ,eol1, eol2, eol3
  50.    ,dlfile
  51.    ,error
  52.    ;
  53.  
  54.   entry();                               // Updates colors & status bar. 
  55.  
  56. // Only if online.
  57.  
  58.   if (!carrier())  
  59.   { failtone();
  60.     status_wind ("THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  61.     return (-1);
  62.   }
  63.  
  64.   read (bbstype,line);                   // Get current BBS type.
  65.   if (line != thisBBStype)  
  66.   { wrongBBS();                          // Doesn't match script!
  67.     return (-1);
  68.   }
  69.  
  70. // Start tracking.
  71.                  
  72.   t1 = track ("Command:",0);             // Track command.
  73.   t2 = track ("Kommando",0);             // Norwegian.
  74.   t3 = 0;                                // Not used yet.
  75.   mo = track ("--more--", 0);           
  76.   FTD = track ("private file",0);        // Private files to download
  77.                                          // NB: Must differentiate between
  78.   nocon = 0;                             // the two below:
  79.   eol1 = track ("ence Status",0);        // End of list 1
  80.   eol2 = track ("ges in conf",0);        // End of list 2
  81.   eol3 = track ("ence status",0);        // End of list 3
  82.  
  83.   read (filist,filelist);                // Get name of file list.
  84.  
  85.   tmark = timer_start (tol);             // Wait a minute for login
  86.  
  87.   while ((stat=trig()) > 0)              // Check for files to download.
  88.   { if (stat == FTD)                     // Files to download?
  89.     { track_free(stat);
  90.       FTD = 0;
  91.       read (short,line);                 // Get short BBS name.
  92.       strcat (line,".DL");               // Add DL extension.
  93.       t3 = track ("^J");                 // Start tracking linefeeds.
  94.       i = -1;                            // Not first line!
  95.       dlfile = fopen (line,"a");         // Try open <BBS>.DL
  96.     }
  97.     else if (stat == t1)                 // Command?
  98.       goto proceed;                      // Something lost here!
  99.  
  100.     else if (stat == t2)                 // Norwegian command???
  101.       english();                         // Redefine to English.
  102.  
  103.     else if (stat == t3)                 // File to download?
  104.     { if (++i)                           // So log this line.
  105.       { track_free (stat);               // Stop tracking.
  106.         terminal();
  107.         vgetchrs(0,gety()-1,line,0,80);  // Get previous line.
  108.         l=strlen(line);
  109.         while (1)
  110.         { if (--l < 0) goto ignore;      // All blanks. Ignore.
  111.           if (subchr(line,l) > ' ')      // Get rid of trailing blanks.
  112.             break;
  113.         }
  114.         setchr (line,++l,0);             // Terminate line.
  115.  
  116.         fputs (line,dlfile);             // Write it to file.
  117.         fputs ("^M^J",dlfile);
  118. ignore: continue;                        // Continue loop.
  119.       }
  120.     }
  121.     else if (stat==eol1 || stat==eol2)   // Conference Status:
  122.       goto proceed;                      // "Good" breakout.
  123.  
  124.     else if (stat == eol3)               // Info conference status:
  125.     { nocon = 1;                         // Conference Status
  126.       goto proceed;                      // not displayed.
  127.     }
  128.     else if (stat == mo)                 // MORE? Just stop this for now.
  129.       cputs ("N^M");
  130.   }
  131.   if (!carrier()) return (-1);
  132.  
  133. proceed:
  134.   release();                             // Release tracks and timer.
  135.   if (dlfile) fclose(dlfile);            // Close .dl file if open.
  136.  
  137.   messages = 0;                          // Preset to no messages.
  138.   t1 = track ("<0> new m",0);            // No messages.
  139.   t2 = track ("No new me",0);            // No message.
  140.   t3 = track ("w message",0);            // One or more message.
  141.   t4 = track ("? for menu)",0);          // Command (non-expert)
  142.   t5 = track ("Command:",0);             // Command (Expert)
  143.   t6 = track ("Kommando",0);             // Norwegian????
  144.   t7 = track ("--more--",0);           
  145.  
  146.   tmark = timer_start (tol);             // Give me a minute.
  147.  
  148.   while ((stat=trig()) > 0)              // Check for messages.
  149.   { if (stat==t1 || stat==t2)            // No message: Subtract one because
  150.       --messages;                        // t3 triggers on this one too.
  151.  
  152.     else if (stat == t3)                 // Any message:
  153.     { ++messages;                        // Yes, add up mess. counter.
  154.       track_free(t1);                    // Now ignore "<0> new messages"
  155.       track_free(t2);                    // and "No new messages".
  156.     }
  157.     else if (stat == t4)                 // Non-expert?
  158.     { cputs ("U X E^M");                 // Tell him I'm an expert!
  159.       track_free(stat);                  // Release this tracking.
  160.     }
  161.     else if (stat == t5)                 // Main command  
  162.       goto NextCommand;
  163.  
  164.     else if (stat == t6)                 // Norwegian commands????
  165.       english();                         // Redefine to English.
  166.  
  167.     else if (stat == t7)
  168.       cputs ("N^M");                     // MORE? Just stop this for now.
  169.   }
  170.   if (!carrier()) return (-1);
  171.  
  172. NextCommand:
  173.   release();                             // Release tracks and timer.
  174.  
  175.   flush();                               // Eat output.
  176.   cputs ("U L 0 T ");                    // Continuous output.
  177.   read (hprot,hisprot);                  // Make sure protocol is
  178.   cputs (hisprot);                       // whatever defined in
  179.   cputs (" W^M");                        // the phone directory. Get
  180.                                          // list of who's on.
  181.   command = "Command:";                  // Set MBBS command prompt.
  182.   write (prompt,command);
  183.  
  184.   t1 = track (command,0);                // Use it for tracking.
  185.   t2 = track ("ter enabl",0);            // Filter still enabled?
  186.   t3 = track ("ter disab",0);            // Filter disabled?
  187.   tmark = timer_start (tol);             // Give me a minute.
  188.   filter = 1;
  189.  
  190.   while ((stat=trig()) > 0)              // Until filter is off:     
  191.   { if (stat==t1)                        // Command:
  192.     { if (!filter) break;                // Filter off?
  193.       flush();
  194.       cputc (219);                       // Write an ASCII 219 to the port.
  195.       filter=cgetct(3)!=219;             // Did it return unchanged?
  196.       cputc (8);                         // Delete the ASCII 219 w/ backspace.
  197.